<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String contextPath = request.getContextPath();
%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	    <meta content="width=device-width, minimum-scale=1,initial-scale=1, maximum-scale=1, user-scalable=1" id="viewport" name="viewport" />
	    <meta content="yes" name="apple-mobile-web-app-capable" />
	    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
	    <meta content="telephone=no" name="format-detection" />
	    <link rel="stylesheet" type="text/css" href="<%=basePath %>xydk/css/mui.min.css"/>
	    <link rel="stylesheet" type="text/css" href="<%=basePath %>xydk/css/style.css"/>
	    <link rel="stylesheet" type="text/css" href="<%=basePath %>xydk/css/mui.picker.css"/>
	    <link rel="stylesheet" type="text/css" href="<%=basePath %>xydk/css/mui.poppicker.css"/>
		<script type="text/javascript" src="<%=basePath %>v2/console/js/jquery-1.9.1.min.js" ></script>
		<title>校咖汇</title>
	</head>
	<body id="allModel">
		<script src="<%=basePath %>xydk/js/fastclick.js"></script>
	    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
		<script src="<%=basePath %>xydk/js/mui.min.js"></script>
		<script src="<%=basePath %>xydk/js/template.js"></script>
		<script src="<%=basePath %>xydk/js/mui.picker.js"></script>
		<script src="<%=basePath %>xydk/js/mui.poppicker.js"></script>
		<script src="<%=basePath %>xydk/js/city.data.js"></script>
		<script src="<%=basePath %>xydk/js/shcool.data.js"></script>
		<script src="<%=basePath %>xydk/js/user_info.html.js"></script>
		
		<script id="modelContent" type="text/html">
			<div class="mui-content mui-scroll-wrapper user-box">
			    <div class="mui-scroll">
			    	<figure>
			    		<img src=<%=basePath %>xydk/{{banner}}>
			    	</figure><!--焦点图-->
			    	
			    	<nav id="nav" class="user-nav">
			    		{{each list as value i}} {{if i==0}}
			    			<a class="active" onclick="changeFlagBase();" id="tabOne">{{list[i].nav}}</a>
			    		{{/if}} {{if i>0}}
			    			<a onclick = "changeFlagPerson();" id="tabTwo">{{list[i].nav}}</a>
			    		{{/if}} {{/each}}
			    	</nav><!--导航-->
			    	
			    	<form id="userInfo" class="user-info" action="" method="post">
			    		{{each list as value i}} 
				    		<div class="mui-input-group">
				    			{{if i==0}}
				    				{{each list[i].tab as value j}} {{if value.status == 0}}
						    			<div class="mui-input-row">
						    				<a>{{value.title}}</a>
						    				<input id={{value.id}} type="text" placeholder={{value.tips}}>
						    			</div>
						    		{{/if}} {{if value.status == 1}} 
						    			<div id={{value.id}} class="mui-input-row">
								           <a>{{value.title}}</a>
								           <span class="result-tips">{{value.tips}}</span>
								           <span class="show-result"></span>
								           <i class="mui-icon mui-icon-arrowdown"></i>
								           <div id="activeTypeResult"></div>
								        </div>	
						    		{{/if}} {{if value.status == 2}}
						    			<div class="mui-input-row textarea-cell">
								           <a>{{value.title}}</a>
								           <textarea rows="3" id={{value.id}} placeholder={{value.tips}}></textarea>
								      	</div>
						    		{{/if}} {{if value.status == 3}}
						    			<div class="mui-input-row skill-show">
								           <a>{{value.title}}</a>
								           <div class="skill-show-list">
								           		{{each list[i].tab[j].skill as value i}}
									           		<div class="skill-show-item">
									           			<div class="skill-show-header">
									           				<h1>{{value.title}}</h1>
									           				<span>{{value.tips}}</span>
									           				<div class="skill-show-body">
									           				</div>
									           				<i class="mui-icon mui-icon-plus"><input type="file"></i>
									           			</div>
									           		</div>
								           		{{/each}}
								           </div>
								      	</div>
						    		{{/if}} {{if value.status == 4}} 
						    			<div class="mui-input-row mui-input-range">
								           <a>{{value.title}}</a>
								           <span id='block-range-val'>{{value.price}}</span>
								           <input type="range" id='block-range' value="5000" step="100" min="0" max="10000" >
								      	</div>
						    		{{/if}} {{if value.status == 5}}
						    			<div class="mui-input-row mui-radio">
								           <a>{{value.title}}</a>
								           <div class="serve-radio">
								           		{{each list[i].tab[j].radio as value i}}
									           		<span>
									           			<input name="radio1"  type="radio">
									           			<i>{{value}}</i>
									           		</span>
								           		{{/each}}
								           </div>
								      	</div>
						    		{{/if}}{{if value.status == 6}}
						    			<div class="mui-input-row">
						    				<a>{{value.title}}</a>
						    				<input id={{value.id}} type="number" placeholder={{value.tips}}>
						    			</div>
						    		{{/if}} {{/each}}
				    			{{/if}}
								{{if i==1}}
				    			<div class="user-skill-list" id="skillList">
					    			<div class="user-skill-list-cell" id="addSkill">
										<h2>
											<span></span>
											<b>点击添加技能</b>
											<i class="mui-icon mui-icon-plus"></i>
											<i class="mui-icon mui-icon-minus"></i>
										</h2>
									</div>		
					    		</div><!--个人技能列表-->
						    		<div class="mui-input-group-child">
						    			{{each list[i].tab as value j}} {{if value.status == 0}}
							    			<div class="mui-input-row">
							    				<a>{{value.title}}</a>
							    				<input id={{value.id}} type="text" placeholder={{value.tips}}>
							    			</div>
							    		{{/if}} {{if value.status == 1}} 
							    			<div id={{value.id}} class="mui-input-row">
									           <a>{{value.title}}</a>
									           <span class="result-tips">{{value.tips}}</span>
									           <span class="show-result"></span>
									           <i class="mui-icon mui-icon-arrowdown"></i>
									           <div id="activeTypeResult"></div>
									        </div>	
							    		{{/if}} {{if value.status == 2}}
							    			<div class="mui-input-row textarea-cell">
									           <a>{{value.title}}</a>
									           <textarea id={{value.id}} rows="3" placeholder={{value.tips}}></textarea>
									      	</div>
							    		{{/if}} {{if value.status == 3}}
							    			<div class="mui-input-row skill-show">
									           <a>{{value.title}}</a>
									           <div class="skill-show-list">
									           		{{each list[i].tab[j].skill as value i}}
										           		<div class="skill-show-item">
										           			<div class="skill-show-header">
										           				<h1>{{value.title}}</h1>
																<div class="handel-input">
											           				{{if i==0}}
											           					<span>{{value.tips}}</span>
											           				{{/if}} {{if i>0}}
											           					<input class="link-input" type="text" placeholder={{value.tips}} />
											           				{{/if}}
											           				{{if i==0}}
											           					<i class="mui-icon mui-icon-plus" onclick="chooseImage();"></i>
											           				{{/if}} {{if i>0}}
											           					<i class="mui-icon mui-icon-plus"></i>
											           				{{/if}}
										           				</div>
																
										           				<div class="skill-show-body" id={{value.id}}>
																	{{if i==0}}
																	{{/if}}
										           				</div>
																
										           			</div>
										           		</div>
									           		{{/each}}
									           </div>
									      	</div>
							    		{{/if}} {{if value.status == 4}} 
							    			<div class="mui-input-row mui-input-range">
									           <a>{{value.title}}</a>
									           <span id='block-range-val'>{{value.price}}</span>
									           <input type="range" id='block-range' value="5000" step="100" min="0" max="10000" >
									      	</div>
							    		{{/if}} {{if value.status == 5}}
							    			<div class="mui-input-row mui-radio">
									           <label>{{value.title}}</label>
									           <div class="serve-radio">
									           		{{each list[i].tab[j].radio as value i}}
										           		<span>
										           			<input name="radio1" id="radio{{i}}" type="radio" value="{{value.value}}">
										           			<i>{{value.title}}</i>
										           		</span>
									           		{{/each}}
									           </div>
									      	</div>
							    		{{/if}} {{if value.status == 6}}
						    						<div class="mui-input-row">
						    						<a>{{value.title}}</a>
						    						<input id={{value.id}} type="number" placeholder={{value.tips}}>
						    						</div>
						    					{{/if}} {{/each}}
						    		</div>
						    	{{/if}}
				    		</div>
				    	{{/each}}
			    	</form>
			    	<div class="user-btn">
			    		<button class="mui-btn mui-btn-block" id="saveBtn">保存</button>
			    		<button class="mui-btn mui-btn-block" id="submitBtn">提交</button>
			    	</div>
			    </div>
			</div>
		</script>
		<script id="skillListItem" type="text/html">
			{{each skillList as value i}} {{if i<skillList.length}}
				<div id="editId{{i}}">
				<div class="user-skill-list-cell">
					<h2>
						<span>技能{{i+1}}</span>
						<i class="mui-icon mui-icon-compose"></i>
					</h2>
					<div class="summariy">
			    		<img src="{{skillList[i].imageStr}}"/>
			    		<div class="summariy-body">
			    			<h1>{{skillList[i].subTitle}} <span>{{if skillList[i].serviceType==1}}线上{{/if}} {{if skillList[i].serviceType==2}}线下{{/if}}</span></h1>
			    			<p>{{skillList[i].details}}</p>
			    			<h2>{{skillList[i].price}}</h2>
			    		</div>
				    	<div class="handle-btn">
				    		<a class="edit-btn" id="edit{{i}}" editId="edit{{i}}" skId="{{skillList[i].id}}">编辑</a>
				    		<a class="del-btn" id="del{{i}}" skId="{{skillList[i].id}}" divDD="editId{{i}}">删除</a>
				    	</div>
			    	</div><!--概要-->
				</div>
				</div>
				{{/if}} {{if i == skillList.length-1}}
				<div class="user-skill-list-cell" id="addSkill">
					<h2>
						<span>{{skillList[i].title}}</span>
						<b>点击添加新技能</b>
						<i class="mui-icon mui-icon-plus"></i>
						<i class="mui-icon mui-icon-minus"></i>
					</h2>
				</div>
				{{/if}}
			{{/each}}
		</script>
		<!-- 分享begin-----------ln -->
		 <script>
		    function toShare() {
		        //获取当前浏览器url全路径,如: http://zhoubang85.com/chooseWXPay.jsp
		        var clientUrl = window.location.href;
		        var imgShareUrl = '<%=basePath%>'
		        var temp = "wapstyle/img/logo2.png"; 
		        imgShareUrl = imgShareUrl+temp;
		        var reqPath="<%=basePath%>/skillUser/getJSConfig.html";
				//请求后台，获取jssdk支付所需的参数
				$.ajax({
					type : 'post',
					url : reqPath,
					dataType : 'json',
					data : {
						"clientUrl" : clientUrl
					//当前页面所在的浏览器URL全路径,由于该支付为jssdk支付，所以需要url地址.参与后台sign签名
					},
					cache : false,
					error : function() {
						alert("系统错误，请稍后重试");
						return false;
					},
					success : function(data) {
						//微信支付功能只有微信客户端版本大于等于5.0的才能调用
						var return_date = eval(data);
						if (parseInt(data[0].agent) < 5) {
							alert("您的微信版本低于5.0无法使用微信支付");
							return;
						}
						//JSSDK支付所需的配置参数，首先会检查signature是否合法。
						wx.config({
							debug : !true, //开启debug模式，测试的时候会有alert提示
							appId : return_date[0].appId, //公众平台中-开发者中心-appid
							timestamp : return_date[0].config_timestamp, //时间戳
							nonceStr : return_date[0].config_nonceStr, //随机字符串,不长于32位
							signature : return_date[0].config_sign, //这里的signature是后台使用SHA1签名算法得出，不是MD5，与下面的wx.chooseWXPay中的paySign不同，下面的paySign是后台使用MD5加密得出
							jsApiList : [ 'onMenuShareAppMessage' ]
						});
		
						//上方的config检测通过后，会执行ready方法
						wx.ready(function() {
							wx.onMenuShareAppMessage({
							    title: '校园大咖', // 分享标题
							    desc: "大咖入驻", // 分享描述
							    link: clientUrl, // 分享链接
							    imgUrl: imgShareUrl, // 分享图标
							    type: '', // 分享类型,music、video或link，不填默认为link
							    dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
							    success: function () { 
							        // 用户确认分享后执行的回调函数
							    },
							    cancel: function () { 
							        // 用户取消分享后执行的回调函数
							    }
							});
							wx.onMenuShareTimeline({
								title: '校园大咖', // 分享标题
							    desc: "大咖入驻", // 分享描述
							    link: clientUrl, // 分享链接
							    imgUrl: imgShareUrl, // 分享图标
							    type: '', // 分享类型,music、video或link，不填默认为link
							    dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
							    success: function () { 
							        // 用户确认分享后执行的回调函数
							    },
							    cancel: function () { 
							        // 用户取消分享后执行的回调函数
							    }
							});
						});
						wx.error(function(res) {
							//alert(res.errMsg);
						});
					}
				});
			}
		    window.onload = toShare();
		</script>
   	<!-- 分享end-----------ln -->
		<script>
		var flag = 0;
		var schoolId = "";
		var minCategory = "";
		var imgPath="";
		//技能修改时ID
		var skiDD = "";
		//修改基本信息是ID
		var basicDD ="";
		var divTabFlag = false;
		var flag1 = ${divFlag};
			(function($,doc){
				
				var schoolData = ${citySchoolList};
				var maxMinCategory = ${maxMinCategory};
				var skillList = ${skillList};
				mui.init();
				//页面数据
				var data = template('modelContent',myData);
				if(skillList!=false){
					var skillIData = template('skillListItem',skillList);
				}
				document.getElementById('allModel').innerHTML = data;
				if(skillList!=false){
					document.getElementById('skillList').innerHTML = skillIData;
				}
				
				
				//禁用滚动条
				document.getElementsByTagName('body')[0].addEventListener('touchmove', function (e) {
				  e.preventDefault();
				});
				
				//自定义滚动条
				var deceleration = mui.os.ios ? 0.003 : 0.0009;
				$('.mui-scroll-wrapper').scroll({
					bounce: true,
					indicators: true, //是否显示滚动条
					deceleration: deceleration
				});
				//阻止点击穿透
				/* window.addEventListener('load', function() {
				    FastClick.attach(document.body);
				}, false); */
				//弹窗
				$.ready(function() {
					//城市
					var cityPicker = new $.PopPicker({
						layer: 2
					});
					/* cityPicker.setData();
					var showCityPickerButton = doc.getElementById('city');
					showCityPickerButton.addEventListener('tap', function(event) {
						cityPicker.show(function(items) {
							document.querySelector('#city .result-tips').style.display = "none";
							document.querySelector('#city .show-result').innerText = items[1].text;
							//返回 false 可以阻止选择框的关闭
							//return false;
						});
					}, false); */
					
					//院校
					var shcoolPicker = new $.PopPicker({
						layer:2
					});
					shcoolPicker.setData(schoolData);
					var showShcoolPickerButton = doc.getElementById('school');
					showShcoolPickerButton.addEventListener('tap', function(event) {
						shcoolPicker.show(function(items) {
							document.querySelector('#school .result-tips').style.display = "none";
							document.querySelector('#school .show-result').innerText = items[1].text;
							schoolId = items[1].value;
							//返回 false 可以阻止选择框的关闭
							//return false;
						});
					}, false);
					
					//技能类型
					var skillPicker = new $.PopPicker({
						layer: 2
					});
					skillPicker.setData(maxMinCategory);
					var showSkillPickerButton = doc.getElementById('skillType');
					showSkillPickerButton.addEventListener('tap', function(event) {
						skillPicker.show(function(items) {
							document.querySelector('#skillType .result-tips').style.display = "none";
							document.querySelector('#skillType .show-result').innerText = items[1].text;
							minCategory = items[1].value;
							//返回 false 可以阻止选择框的关闭
							//return false;
						});
					}, false);
				});
				
				//监听input事件，获取range的value值，也可以直接element.value获取该range的值
				var rangeList = document.querySelectorAll('input[type="range"]');
			    for(var i=0,len=rangeList.length;i<len;i++){
			        rangeList[i].addEventListener('input',function(){
			            if(this.id.indexOf('field')>=0){
			                document.getElementById(this.id+'-input').value = this.value;
			            }else{
			                document.getElementById(this.id+'-val').innerHTML = this.value;
			            }
			            
			
			        });
			    }
			    
			    //选项卡切换
			    if(flag1!=1){
					var nav = document.getElementById('nav');
					var navTag = nav.getElementsByTagName('a');
					var tabTag = document.getElementsByClassName('mui-input-group');
					var len = navTag.length;
					var i = 0;
					tabTag[0].style.display = "block";//显示我的信息表单;
					for(var i=0;i<len;i++){
						navTag[i].index = i;
						navTag[i].addEventListener('tap',function(){
							for(i=0; i<len; i++){
							    navTag[i].className = '';
							    tabTag[i].style.display = "none";
						    }
						   navTag[this.index].className = 'active';
						   tabTag[this.index].style.display = "block";
						});
					}
					
			    }
				//个人技能列表点击编辑按扭显示操作框
				mui('.user-skill-list-cell').on('tap','.mui-icon-compose',function(){
					var handelBtn = document.getElementsByClassName('handle-btn');
					var thisSumariy = this.parentNode.parentNode.childNodes[3].childNodes[5];
					for(i=0;i<handelBtn.length;i++){
						handelBtn[i].style.display = "none";
					}
					thisSumariy.style.display = "block";
				});
				
				//删除弹窗
				mui('.handle-btn').on('tap','.del-btn',function(){
					var dId = this.getAttribute("divdd");
					var sId = this.getAttribute("skid");
					var btnArray = ['取消', '确认'];
					var handelParent = this.parentNode;
					var sumariy = handelParent.parentNode;
					var skillCell = sumariy.parentNode;
					mui.confirm('确定删除此技能？', '？', btnArray, function(e) {
						if (e.index == 1) {
							
							/* document.getElementsByClassName('user-skill-list')[0].removeChild(skillCell) */
							/* <a class="del-btn" id="del{{i}}" skId="{{skillList[i].id}}" divDD="editId{{i}} */
							$.ajax({
								type : "post",
								url : "<%=basePath%>skillUser/deleteSkillInfo.html",
								dataType : "json",
								data : {skillId:sId},
								success : function(data) {
									if(data.flag==true){
										alert("删除成功!");
										document.getElementById(dId).removeChild(skillCell);
										return;
									}else{
										alert("删除失败!");
									}
								}
							});
						} else {
							return false;
						}
					})
				});
				
				//点击编辑按扭
				mui('.handle-btn').on('tap','.edit-btn',function(){
					 /* editId="edit{{i}}" skId="{{skillList[i].id} */
					 var id = this.id;
					 var e = document.getElementById(id);
					 var i = e.getAttribute("editId");
					 var j = e.getAttribute("skId");
					 toEditSkillInfo(i,j);
					 
					var submitBtn = document.getElementById('submitBtn');
					var saveBtn = document.getElementById('saveBtn');
					document.querySelector('.user-skill-list').style.display = 'none';
					document.querySelector('.mui-input-group-child').style.display = 'block';
					submitBtn.style.display = 'none';
					saveBtn.style.display = "block";
				});
				
				//占击添加按扭
				document.querySelector('.mui-icon-plus').addEventListener('tap',function(){
					divTabFlag = false;	
					var skillList = document.querySelector('.user-skill-list');
					var skillCell = skillList.getElementsByClassName('user-skill-list-cell');
					var skillForm = document.querySelector('.mui-input-group-child');
					var minus = document.querySelector('.mui-icon-minus');
					var len = skillCell.length;
					this.style.display = "none";
					minus.style.display = "block";
					setTimeout(function(){
						skillForm.style.display = "block";
					},320)
				});
				//添加链接
				for(var i=1;i<document.querySelectorAll('.skill-show-item').length;i++){
					document.querySelectorAll('.mui-icon-plus')[i+1].addEventListener('tap',function(){
					if(this.parentElement.nextElementSibling.children.length<3){
							var val = this.parentElement.children[0].value;//输入框的值
							this.parentElement.children[0].value="";
							var linkBody = document.getElementsByClassName('skill-show-body');
							var a = document.createElement('a');
							//console.log(this.parentElement.nextElementSibling.children.length);
							
							if(val==''){
								alert("链接不能为空")
								return false;
							}
							     var reg = /(http|ftp|https):\/\/([\w.]+\/?)\S*/;
							if(reg.test(val)!=true){
								alert("链接不合法!");
								return false;
							}
							a.innerHTML = '<span style="color:#f00" >'+ val +'</span>'  +
							              '<span class="mui-icon mui-icon-closeempty"></span>';
							this.parentElement.nextElementSibling.style.display = "block";
							this.parentElement.nextElementSibling.appendChild(a);
					 }else{
						 alert("最多添加三个链接!");
						 return ;
					 }
					});
				}
				//删除链接
				mui('.skill-show-body').on('tap','.mui-icon-closeempty',function(){
						var showBody = this.parentElement.parentElement;
						var thisItem = this.parentElement;
						if(showBody.children.length == 1){
							showBody.style.display = "none";
						}
						showBody.removeChild(thisItem);
				})
				//占击缩减按扭
				document.querySelector('.mui-icon-minus').addEventListener('tap',function(){
					var skillList = document.querySelector('.user-skill-list');
					var skillCell = skillList.getElementsByClassName('user-skill-list-cell');
					var skillForm = document.querySelector('.mui-input-group-child');
					var plus = document.querySelector('.mui-icon-plus');
					var len = skillCell.length;
					this.style.display = "none";
					plus.style.display = "block";
					skillForm.style.display = "none";
				});
				
				//点击保存按扭
				document.getElementById('saveBtn').addEventListener('tap',function(){
					aa();
					if(divTabFlag){
						var nav = document.getElementById('nav');
						var navTag = nav.getElementsByTagName('a');
						var tabTag = document.getElementsByClassName('mui-input-group');
						var skillForm = document.querySelector('.mui-input-group-child');
						var submitBtn = document.getElementById('submitBtn');
						var skillList = document.querySelector('.user-skill-list');
						var handelBtn = document.getElementsByClassName('handle-btn');
						var len = navTag.length;
						for(i=0;i<len;i++){
							navTag[i].className = "";
							tabTag[i].style.display = 'none';
						}
						for(i=0;i<handelBtn.length;i++){
							handelBtn[i].style.display = 'none';
						}
						navTag[len-1].className = "active";
						tabTag[len-1].style.display = "block";
						skillForm.style.display = "none";
						/*this.style.display = "none";
						 submitBtn.style.display = "block"; */
						 skillList.style.display = "block";	
					}
				});
			})(mui,document);
			
			function aa(){
				if(flag==0){
					var userName = $("#name").val();
					var phoneNumber = $("#tel").val();
					var email = $("#email").val();
					var wxNumber = $("#weixin").val();
					var aboutMe = $("#aboutMe").val();
					
					if(userName==""){
						alert("请输入用户名");
						return;
					}
					if(schoolId==""){
						alert("请选择学校!");
						return;
					}
					if(phoneNumber.trem==""){
						alert("请输入手机号");
						return;
					}else{
						var reg=/^\d+$/;
						if(reg.test(phoneNumber)!=true){
						    alert("请输入正确的手机号!");
						    return ;
						}
						if(phoneNumber.length!=11){
							alert("请输入正确的手机号!");
							return ;
						}
					}
					if(email.trem==""){
						alert("请输入邮箱地址!");
						return;
					}else{
						if(email.indexOf("@")<0){
							alert("请输入正确的邮箱地址!");
							return ;
						}
					}
					
					if(wxNumber.trem==""){
						alert("请输入微信号!");
						return;
					}else{
												
						 /* var r = /^[a-zA-Z][a-zA-Z0-9]*$/;  */
						var r = /^[a-zA-Z][0-9a-zA-z-_]*$/;
						if(r.test(wxNumber)!=true){
							alert("请输入正确的微信号!");
							return ;
						}
						if(wxNumber.length<6||wxNumber.length>20){
							alert("微信号为6至20位!");
							return ;
						}
					}
					if(aboutMe.trem==""||aboutMe.length<15){
						alert("请填写关于您的介绍,不低于15字");
						return ;
					}
					if(basicDD==""){
						alert("正在处理");
						$.ajax({
							type : "post",
							url : "<%=basePath%>skillUser/addSkillUserBaseInfo.html",
							dataType : "json",
							data : {userName:userName,phoneNumber:phoneNumber,email:email,wxNumber:wxNumber,aboutMe:aboutMe,schoolId:schoolId},
							success : function(data) {
								if(data.flag==true){
									/* alert("基本信息保存成功!"); */
									window.location.href="<%=basePath%>/skillUser/toAddSkillUser.html";
									return;
								}else{
									alert("基本信息保存失败!");
								}
							}
						});
					}else{
						alert("正在处理");
						$.ajax({
							type : "post",
							url : "<%=basePath%>skillUser/editBasicInfo.html",
							dataType : "json",
							data : {userName:userName,phoneNumber:phoneNumber,email:email,wxNumber:wxNumber,aboutMe:aboutMe,schoolId:schoolId,basicId:basicDD},
							success : function(data) {
								if(data.flag==true){
									/* alert("基本信息修改成功!"); */
									window.location.href="<%=basePath%>/skillUser/toAddSkillUser.html";
									return;
								}else{
									alert("基本信息修改失败!");
								}
							}
						});
					}
				}
				var basicId = ${basicId};
				
				if(flag==1){//技能保存 
						//basicId ="123123";
						var skillName = $("#skillName").val();
						var videoURL = "";
						var textURL = "";
						var skillPrice = $("#skillPrice").val();
						var skillDepict = $("#skillDepict").val();
						var serviceType = $("input:radio[name='radio1']:checked").val();
						/* imgPath = "101,202,303"; */
						/* imgPath = imgPath; */
						/* alert(skillName+"---"+videoURL+"---"+textURL+"---"+skillPrice+"---"+skillDepict+"---"+minCategory+"---"+serviceType+"---"+imgPath+"---"+basicId); */
						/* var g = $(".skill-show-body a"); */
						var g = $("#vedioLink a");
						for(var i =0;i<g.length;i++){
							videoURL+=g[i].text+",";
						}
						var m = $("#otherLink a");
						for(var j =0;j<m.length;j++){
							textURL+=m[j].text+",";
						}
						textURL = textURL.substring(0,textURL.length-1);
						videoURL = videoURL.substring(0,videoURL.length-1);
						if(skillName==""){
							alert("技能名称不能为空");
							return false;
						}
						if(skillPrice==""){
							alert("技能价格不能为空!");
							return false;
						}else{
							var reg = /^[0-9]+(.[0-9]{2})?$/;
							if(reg.test(skillPrice)!=true){
								alert("请输入正确的价格!");
							}
						}
						if(skillDepict==""||skillDepict.length<20){
							alert("请填写技能介绍，不低于20字!");
							return false;
						}
						if(serviceType==""){
							alert("服务类型不能为空!");
							return false;
						}
						var imgArr = $("#imgId img");
						//循环获取各个图片的链接
						imgPath="";
						for(var i=0;i<imgArr.length;i++){
							var imgPathTemp = $($("#imgId img")[i]).attr("imgpath");
							imgPath += imgPathTemp+",";
						}
						imgPath = imgPath.substring(0,imgPath.length-1);//截取最后出现的逗号
						if(imgPath==""){
							alert("图片不能为空!");
							return ;
						}else{
							var imgPathStr = imgPath.split(",");
							/* alert(imgPathStr.length); */
							/* alert(imgPathStr.length); */
							if(imgPathStr.length<3){
								alert("图片至少为三张!");
								return ;
							}
						}
						if(skiDD==""){
							alert("正在处理");
							/* alert("保存"); */							
							$.ajax({
								type : "post",
								url : "<%=basePath%>skillUser/addSkillInformation.html",
								dataType : "json",
								data : {skillName:skillName,videoURL:videoURL,textURL:textURL,skillPrice:skillPrice,skillDepict:skillDepict,serviceType:serviceType,imgPath:imgPath,basicId:basicId,skillSonId:minCategory},
								success : function(data) {
									/* alert(imgPath);	 */								
									if(data.flag==true){
										/* alert("基本信息保存成功!"); */
										divTabFlag = true;
										window.location.href="<%=basePath%>/skillUser/toAddSkillUser.html";
										return;
									}else{
										alert("技能信息保存失败!");
									}
								}
							});
						}
						if(skiDD!=""){
							alert("正在处理");
							$.ajax({
								type : "post",
								url : "<%=basePath%>skillUser/editSkillInfo.html",
								dataType : "json",
								data : {skillName:skillName,videoURL:videoURL,textURL:textURL,skillPrice:skillPrice,skillDepict:skillDepict,serviceType:serviceType,imgPath:imgPath,basicId:basicId,skillSonId:minCategory,skillId:skiDD},
								success : function(data) {
									if(data.flag==true){
										/* alert("基本信息修改成功!"); */
										/* alert(imgPath); */
										divTabFlag = true;
										window.location.href="<%=basePath%>/skillUser/toAddSkillUser.html";
										return;
									}else{
										alert("技能信息修改失败!");
									}
								}
							});
						}
				}
			}
			//设置切换标记
			function  changeFlagBase(){
				flag = 0;
			}
			//设置切换标记
			function  changeFlagPerson(){
				if(flag1!=1){
					flag = 1;
				}
			}
			//去编辑技能信息
			function toEditSkillInfo(flagId,skillId){
				var divStr = "";
					$.ajax({
						type : "post",
						url : "<%=basePath%>skillUser/toEditSkillInfo.html",
						dataType : "json",
						data : {skillId:skillId},
						success : function(data){
							var skillName = $("#skillName").val(data.skillInfo.skillName);
							var videoURL = data.skillInfo.videoURL;
							/* if(videoURL.indexOf(",")<0){
								$("#vedioLink").css('display','none');
							}else{ */
								var videoArr = videoURL.split(",");
							if(videoArr.length>0&&videoArr[0]!=""){
								$("#vedioLink").show();
								var vidioLink =$("#vedioLink");
								var ia="";
								for(var i=0;i<videoArr.length;i++){
									if(videoArr.length>1&&i!=videoArr.length-1){
										ia +="<a>"+videoArr[i]+
							              '<span class="mui-icon mui-icon-closeempty"></span></a>';										
									}else{
										ia +="<a>"+videoArr[i]+
							              '<span class="mui-icon mui-icon-closeempty"></span></a>';
									}
									
								}
								 vidioLink.append(ia);
							}
							/* } */
							var textURL = data.skillInfo.textURL;
							/* if(textURL.indexOf(",")<0){
								$("#otherLink").hide();
							}else{ */
								/* alert(otherLink);		 */					
								var textArr = textURL.split(",");
								if(textArr.length>0&&textArr[0]!=""){
									$("#otherLink").show();
									var textLink =$("#otherLink");
									var ib="";
									for(var i=0;i<textArr.length;i++){
										if(textArr.length>1&&i!=textArr.length-1){
											ib +="<a>"+textArr[i]+
								              '<span class="mui-icon mui-icon-closeempty"></span></a>';	
										}else{
											ib +="<a>"+textArr[i]+
								              '<span class="mui-icon mui-icon-closeempty"></span></a>';
										}
									}
									textLink.append(ib);
								}
							/* } */
							$("#skillPrice").val(data.skillInfo.skillPrice);
							var skillDepict = $("#skillDepict").val(data.skillInfo.skillDepict);
							/* var serviceType = $("input:radio[name='radio1']").val() */
							minCategory = data.skillInfo.skillSonId;
							basicId = data.skillInfo.basinId;
							skiDD = data.skillInfo.id;//修改回显ID
							//$("#block-range").val(data.skillInfo.skillPrice);//设置选择条位置
							//设置技能类型
							document.querySelector('#skillType .result-tips').style.display = "none";
							document.querySelector('#skillType .show-result').innerText = data.skillInfo.className;
							//单选按钮回显
							var skillType = data.skillInfo.serviceType;
							if(skillType==1){
								//上
								$("#radio0").attr("checked","checked");
							}
							if(skillType==2){
								//下
								$("#radio1").attr("checked","checked");
							}
							var imgList = data.listSkillImgInfo;
							if(imgList.length>0){
								//循环获取各个图片的链接
								var imgStrEdit="";
								/* var u = "http:\//static.xiaoka360.com/uniformStaticResourceService"; */
								for(var i=0;i<imgList.length;i++){
									imgStrEdit = '<img id="'+i+'"src='+imgList[i].imgURL+' onclick="delImg('+i+','+imgList[i].id+');" imgPath="'+imgList[i].imgURL+'" flag="edit"></img>';
									$("#imgId").append(imgStrEdit);
								}
								//imgPath = imgPath.subString(0,imgPath.length-1);//截取最后出现的逗号
								 /* $('.skill-show-body:first-child').show(); */
								 $('#imgId').show();
							}
							 
						}
					});
			}
			/*选择图片*/
		    function chooseImage() {
				var imgNum = $("#imgId img").length;
				var temNum = 9-imgNum;
				/* alert("剩余上传数量"+temNum); */
				if(temNum<=0){
					alert("最多支持上传9张图片");
					return ;
				}
		        var clientUrl = window.location.href;
		        var reqPath='<%=contextPath%>/skillUser/getJSConfig.html';
				//请求后台，获取jssdk支付所需的参数
				$.ajax({
					type : 'post',
					url : reqPath,
					dataType : 'json',
					data : {
						"clientUrl" : clientUrl
					//当前页面所在的浏览器URL全路径,由于该支付为jssdk支付，所以需要url地址.参与后台sign签名
					},
					cache : false,
					error : function() {
						alert("系统错误，请稍后重试");
						return false;
					},
					success : function(data) {
						//微信支付功能只有微信客户端版本大于等于5.0的才能调用
						var return_date = eval(data);
						
						if (parseInt(data[0].agent) < 5) {
							alert("您的微信版本低于5.0无法使用微信支付");
							return;
						}
						//JSSDK支付所需的配置参数，首先会检查signature是否合法。
						wx.config({
							debug : false, //开启debug模式，测试的时候会有alert提示
							appId : return_date[0].appId, //公众平台中-开发者中心-appid
							timestamp : return_date[0].config_timestamp, //时间戳
							nonceStr : return_date[0].config_nonceStr, //随机字符串,不长于32位
							signature : return_date[0].config_sign, //这里的signature是后台使用SHA1签名算法得出，不是MD5，与下面的wx.chooseWXPay中的paySign不同，下面的paySign是后台使用MD5加密得出
							jsApiList : [ 'chooseImage','uploadImage','downloadImage' ]
						});
						//上方的config检测通过后，会执行ready方法
						wx.ready(function() {
							//uploadImage(wx, "weixin://resourceid/a5d7a699977ccb17c5825011ba0dccf8");
							wx.chooseImage({
							    count: temNum, // 默认9
							    sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
							    sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
							    success: function (res) {
									/* for(var j=0;j<9;j++){
										$("#"+j).hide();	     	
									} */
							        var localIds = res.localIds; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
							       	imgPath = "";
							        var a=0;
							        /* for(var i=0;i<localIds.length;i++){
								        uploadImageSelf(wx,localIds[i],i);
							        } */
							        uploadImageSelf(wx,localIds,a);
							        $('.skill-show-body:first').show();
							    }
							});
		
						});
						wx.error(function(res) {
							alert(res.errMsg);
						});
					}
				});
			}
			
			function uploadImageSelf(wx,localIds,a){
				/* alert("uploadImage="+localIds); */
				 var i=a;
				 var len = localIds.length;
				 var localId = localIds[i];
				wx.uploadImage({
		            localId: localId, // 需要上传的图片的本地ID，由chooseImage接口获得
		            isShowProgressTips: 1, // 默认为1，显示进度提示
		            success: function (res) {
		                var serverId = res.serverId; // 返回图片的服务器端ID
		                i++;
		                downloadImageSelf(wx, serverId,i);
		                /* for(var i=0;i<localIds.length;i++){
			                downloadImageSelf(wx,serverId[i]);
		                } */
		                /* alert("++len="+len+"i="+i+"localId"+localId); */
		                if(i<len){
		                	uploadImageSelf(wx,localIds,i);
		                }
		            }
		        });
			}
			function downloadImageSelf(wx,serverId,i){
				 /* alert("downImg="+serverId);  */
				$.ajax({
		            		type : "post",
		            		url : "<%=contextPath%>/skillUser/downloadImageSelf.html",
		            		dataType : "json",
		            		data : {serverId:serverId},
		            		success : function(data) {//success后添加heidden的input用于保存上传服务器返回地址(删除图片,添加img,添加保存地址,保存时获取值)
		            			imgPath = data.path;
		            			/* alert(imgPath);  */
		            			/* var u = "http:\//static.xiaoka360.com/uniformStaticResourceService"+imgPath; */
		            			var temPara="0";
		            			/* var t="add"+i; */
		            			var inputImgVal = '<img id="'+i+'" src="'+imgPath+'" onclick="delImg('+i+','+temPara+');" imgPath="'+imgPath+'" flag="add"></img>';
		            			/* alert(inputImgVal); */
		            			$("#imgId").append(inputImgVal);
		            			/* var h = $("#imgId").html();
		            			alert(h); */ 
		            			
		            		}
		            	});
		            	/* imgPath = imgPath.subString(0,imgPath.length-1);
		            	$("#path").val(imgPath); */
		            	/* alert(imgPath); */
			   }
			//点击删除图片
			function delImg(id,imgId){
				/* var imId = this.get(id); */
				var delImgFlag = $("#"+id).attr("flag");
				if(confirm("确定删除?")){
					if(delImgFlag=="edit"){
						//表示修改需要数据库删除
						$.ajax({
							type : "post",
							url : "<%=basePath%>skillUser/delImg.html",
							dataType : "json",
							data : {id:imgId},
							success : function(data) {
								if(data.flag){
									$("#"+id).remove();		
								}
							}
						});
					}else{
						$("#"+id).remove();
					}
				}else{
					/* alert("NO"); */
					return ;
				}
				
			}
			window.onload = function(){
				var nav = document.getElementById('nav');
				var navTag = nav.getElementsByTagName('a');
				var tabTag = document.getElementsByClassName('mui-input-group');
				var skillForm = document.querySelector('.mui-input-group-child');
				var skillList = document.querySelector('.user-skill-list');
				if(flag1==1){
					//显示基本信息
					tabTag[1].style.display = "none";
					navTag[1].className = "";
					tabTag[0].style.display = "block";
					navTag[0].className = "active";
					flag=0;
				}
				if(flag1==2){
					//显示列表
					tabTag[0].style.display = "none";
					navTag[0].className = "";
					tabTag[1].style.display = "block";
					navTag[1].className = "active";
					skillList.style.display = "block";
					skillForm.style.display = "none";
					flag=1;
					//设置基本信息
					var userName = $("#name").val("${basicInfo.userName}");
					var phoneNumber = $("#tel").val("${basicInfo.phoneNumber}");
					var email = $("#email").val("${basicInfo.email}");
					var wxNumber = $("#weixin").val("${basicInfo.wxNumber}");
					var aboutMe = $("#aboutMe").val("${basicInfo.aboutMe}");
					schoolId = "${basicInfo.schoolId}";
					basicDD = "${basicInfo.id}"
					document.querySelector('#school .result-tips').style.display = "none";
					document.querySelector('#school .show-result').innerText = "${basicInfo.schoolName}";
				}
				if(flag1==3){
					//显示技能表单填写
					tabTag[0].style.display = "none";
					navTag[0].className = "";
					tabTag[1].style.display = "block";
					navTag[1].className = "active";
					skillList.style.display = "none";
					skillForm.style.display = "block";
					flag=1;
					//设置基本信息
					var userName = $("#name").val("${basicInfo.userName}");
					var phoneNumber = $("#tel").val("${basicInfo.phoneNumber}");
					var email = $("#email").val("${basicInfo.email}");
					var wxNumber = $("#weixin").val("${basicInfo.wxNumber}");
					var aboutMe = $("#aboutMe").val("${basicInfo.aboutMe}");
					schoolId = "${basicInfo.schoolId}";
					basicDD = "${basicInfo.id}"
					document.querySelector('#school .result-tips').style.display = "none";
					document.querySelector('#school .show-result').innerText = "${basicInfo.schoolName}";
				}
			};
		</script>
	</body>
</html>
